package emergence.entities;

import java.awt.Point;

import emergence.game.Tickable;
import emergence.game.gfx.Renderable;
import emergence.game.gfx.Screen;
import emergence.game.level.Level;

public abstract class Entity implements Tickable, Renderable {

    protected Level level;
    protected Point coords;
    protected int xOff, yOff;

    public Entity(Level level) {
        init(level);
    }

    public final void init(Level level) {
        this.level = level;
    }

    @Override
    public abstract void tick();

    public abstract void render(Screen screen);

    public Point getCoords() {
        return coords;
    }

    public void setCoords(Point coords) {
        this.coords = coords;
    }

    protected void updateLocation(Point oldCoords, Point newCoords) {
        setCoords(newCoords);
        level.moveEntity(oldCoords, newCoords);
    }

    public int xOffset() {
        return xOff;
    }

    public int yOffset() {
        return yOff;
    }
}
